// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Security;

public sealed partial class SamlInvalidateRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Submits a SAML LogoutRequest message to Elasticsearch for consumption.
/// </para>
/// </summary>
public sealed partial class SamlInvalidateRequest : PlainRequest<SamlInvalidateRequestParameters>
{
	internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlInvalidate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "security.saml_invalidate";

	/// <summary>
	/// <para>
	/// The Assertion Consumer Service URL that matches the one of the SAML realm in Elasticsearch that should be used. You must specify either this parameter or the realm parameter.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("acs")]
	public string? Acs { get; set; }

	/// <summary>
	/// <para>
	/// The query part of the URL that the user was redirected to by the SAML IdP to initiate the Single Logout.
	/// This query should include a single parameter named SAMLRequest that contains a SAML logout request that is deflated and Base64 encoded.
	/// If the SAML IdP has signed the logout request, the URL should include two extra parameters named SigAlg and Signature that contain the algorithm used for the signature and the signature value itself.
	/// In order for Elasticsearch to be able to verify the IdP’s signature, the value of the query_string field must be an exact match to the string provided by the browser.
	/// The client application must not attempt to parse or process the string in any way.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("query_string")]
	public string QueryString { get; set; }

	/// <summary>
	/// <para>
	/// The name of the SAML realm in Elasticsearch the configuration. You must specify either this parameter or the acs parameter.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("realm")]
	public string? Realm { get; set; }
}

/// <summary>
/// <para>
/// Submits a SAML LogoutRequest message to Elasticsearch for consumption.
/// </para>
/// </summary>
public sealed partial class SamlInvalidateRequestDescriptor : RequestDescriptor<SamlInvalidateRequestDescriptor, SamlInvalidateRequestParameters>
{
	internal SamlInvalidateRequestDescriptor(Action<SamlInvalidateRequestDescriptor> configure) => configure.Invoke(this);

	public SamlInvalidateRequestDescriptor()
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.SecuritySamlInvalidate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

	internal override bool SupportsBody => true;

	internal override string OperationName => "security.saml_invalidate";

	private string? AcsValue { get; set; }
	private string QueryStringValue { get; set; }
	private string? RealmValue { get; set; }

	/// <summary>
	/// <para>
	/// The Assertion Consumer Service URL that matches the one of the SAML realm in Elasticsearch that should be used. You must specify either this parameter or the realm parameter.
	/// </para>
	/// </summary>
	public SamlInvalidateRequestDescriptor Acs(string? acs)
	{
		AcsValue = acs;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The query part of the URL that the user was redirected to by the SAML IdP to initiate the Single Logout.
	/// This query should include a single parameter named SAMLRequest that contains a SAML logout request that is deflated and Base64 encoded.
	/// If the SAML IdP has signed the logout request, the URL should include two extra parameters named SigAlg and Signature that contain the algorithm used for the signature and the signature value itself.
	/// In order for Elasticsearch to be able to verify the IdP’s signature, the value of the query_string field must be an exact match to the string provided by the browser.
	/// The client application must not attempt to parse or process the string in any way.
	/// </para>
	/// </summary>
	public SamlInvalidateRequestDescriptor QueryString(string queryString)
	{
		QueryStringValue = queryString;
		return Self;
	}

	/// <summary>
	/// <para>
	/// The name of the SAML realm in Elasticsearch the configuration. You must specify either this parameter or the acs parameter.
	/// </para>
	/// </summary>
	public SamlInvalidateRequestDescriptor Realm(string? realm)
	{
		RealmValue = realm;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(AcsValue))
		{
			writer.WritePropertyName("acs");
			writer.WriteStringValue(AcsValue);
		}

		writer.WritePropertyName("query_string");
		writer.WriteStringValue(QueryStringValue);
		if (!string.IsNullOrEmpty(RealmValue))
		{
			writer.WritePropertyName("realm");
			writer.WriteStringValue(RealmValue);
		}

		writer.WriteEndObject();
	}
}